<?php
require_once("../../simpletest/autorun.php");
require_once("../../simpletest/unit_tester.php");
//require_once '../../data/IRepository.php';
include '../../paramcsts/Param.php';
require_once ('../../data.impl/UserRepository.php');

class TestUserRepository extends UnitTestCase {
	private $connexion;
	private $userRepoId;
	private $userRepository;
	
	public function setUp(){
		$this->userRepository = new UserRepository();
		$this->userRepoId = "1-M001";
			
	}
	
	public function tearDown(){
		unset($userRepository);
		
	}
	public function testGetObject(){
		try{
			
			$repo = $this->userRepository;
			
			$val = $repo->getObject('12345');
			$this->assertEqual($val->uid,null);
			
			$val = $repo->getObject($this->userRepoId);
			$this->assertEqual($val->uid,"1-M001");
		}
		catch(PDOException $e){
			echo $e->getMessage();
		}
			
	}
	
	public function testInsertObject() {
	/*	
		$repo = $this->userRepository;
		$user = new UserRepo();
		$user->uid='1-R25G';
		$user->password='password';
		$user->login='login';
		$user->name='name';
		$user->token='12dsf654rzfsgfdstg45';
		
		$val = $repo->insertObject($user);
		$this->assertEqual($val,1);*/
	}
	
	public function testDeleteObject() {
		$this->assertTrue(true);
	}
	
	public function testUpdateObject(){
		$repo = $this->userRepository;
		$registered = $repo->getObject('1-R25G');
		$registered->login='log';
		$val = $repo->updateObject($registered);
		
		$this->assertEqual($val,1);
		$reg = $repo->getObject('1-R25G');
		$this->assertEqual($reg->login,"log");
		
		
	}
	
}
?>